package com.dazhi.show.story.vitae.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dazhi.show.core.BaseController;
import com.dazhi.show.core.Result;
import com.dazhi.show.story.emperor.dao.Emperor;
import com.dazhi.show.story.emperor.server.EmperorServiceImpl;
import com.dazhi.show.story.vitae.dao.Vitae;
import com.dazhi.show.story.vitae.server.VitaeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/vitae")
public class VitaeController extends BaseController<VitaeService, Vitae> {
    @Resource
    private VitaeService vitaeService;

    @GetMapping("/getByEmperorId")
    public Result<List<Vitae>> getByEmperorId(Integer emperorId) {
        QueryWrapper<Vitae> queryWrapper = new QueryWrapper<Vitae>().eq("emperor_id", emperorId).orderByAsc("year");
        List<Vitae> vitaeList = vitaeService.list(queryWrapper);
        return new Result<List<Vitae>>(200,"success",vitaeList);
    }
}
